package com.manage.colligationQuery;

import java.sql.SQLException;

import javax.naming.NamingException;

import com.framework.Dao;
import com.util.DBUtil;
import com.util.Parameters;

public class ColligationQueryOfDriverDao extends Dao {
	
	public ColligationQueryOfDriverVo query(ColligationQueryOfDriverVo vo){
		String sql = "select id,name,idcard,level,telephone,mobilephone,createtime,modifytime,drivercertificate from driverinformition where idcard ='"+vo.getIdcard()+"'";
		try {
			return DBUtil.querySingular(sql, new ColligationQueryOfDriverVo());
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (NamingException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (NoSuchFieldException e) {
			e.printStackTrace();
		}
		return null;
	}
	
	public ColligationQueryOfDriverVo update(ColligationQueryOfDriverVo vo){
		Parameters param = DBUtil.getParameters();
		String setSql = this.makeSet(param,vo);
		if(setSql == null || "".equals(setSql))
			return null;
		
		String sql = "UPDATE driverinformition "+ setSql +
		"	WHERE id=? ";
		try {
			param.setString(1, vo.getId());
			if ( 0!=DBUtil.update(param,sql) ) {
				return vo;
			}
		} catch (NamingException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}
}
